Retrieve the length, in characters, of a string in the list of a combo box
#Include <GuiCombo.au3>
_GUICtrlComboGetLBTextLen($h_combobox, $i_index)
Parameters
$h_combobox | control id/control hWnd |
$i_index | Specifies the zero-based index of the string |
Return Value
Success: | Returns is the length of the string, in TCHARs, excluding the terminating null character. |
If an ANSI string this is the number of bytes, and if it is a Unicode string this is the number of characters. | |
Failure: | Returns $CB_ERR if the $i_index parameter does not specify a valid index. |
Remarks
Under certain conditions, the return value is larger than the
Related
_GUICtrlComboSetEditSel
Example
#include <GuiConstants.au3>
#include <GuiCombo.au3>
Opt('MustDeclareVars',1)
Dim $Combo,$Btn_Exit,$Status,$msg
GuiCreate("ComboBox Get LB Text Len", 392, 254)
$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Combo
If(_GUICtrlComboGetCurSel($Combo) <> $CB_ERR) Then
GUICtrlSetData($Status,"Length of Item[" & _GUICtrlComboGetCurSel($Combo) & "] = " & _GUICtrlComboGetLBTextLen($Combo, _GUICtrlComboGetCurSel($Combo)))
EndIf
EndSelect
WEnd
Exit